﻿using System;

namespace MultiThread.DosApp
{
	/// <summary>
	/// 用户
	/// </summary>
	public class User
	{
		/// <summary>
		/// ID
		/// </summary>
		private int _ID = 0;

		/// <summary>
		/// 名称
		/// </summary>
		private String _name = null;

		#region 类构造器
		/// <summary>
		/// 类参数构造器
		/// </summary>
		/// <param name="ID"></param>
		/// <param name="name"></param>
		public User(int ID, String name)
		{
			this.ID = ID;
			this.Name = name;
		}
		#endregion

		/// <summary>
		/// 获取或设置 ID
		/// </summary>
		public int ID
		{
			get
			{
				return this._ID;
			}

			set
			{
				this._ID = value;
			}
		}

		/// <summary>
		/// 获取或设置用户名称
		/// </summary>
		public String Name
		{
			get
			{
				return this._name;
			}

			set
			{
				this._name = value;
			}
		}

		/// <summary>
		/// 打招呼
		/// </summary>
		public void SayHello()
		{
			Console.WriteLine(String.Format("Hello, I'm {0}", this.Name));
		}

		/// <summary>
		/// 去菜园偷菜
		/// </summary>
		public void Thieve()
		{
			// 偷得白菜
			String result = Garden.Instance.Lose();

			if (String.IsNullOrEmpty(result))
			{
				// 什么都没得到
				Console.WriteLine(String.Format("Nothing, {0}", this.Name));
			}
			else
			{
				// 得到白菜
				Console.WriteLine(String.Format("yeah, {0} Got {1}", this.Name, result));
			}
		}
	}
}
